<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:form id="formFilCot">
	<p:panel header="#{message.label_cotacoes} - #{message.label_filtro}"
		style="position: relative; left:10%;">
		<h:panelGrid columns="6">

			<h:outputLabel value="#{message.label_emissao_de}" />
			<p:inputMask style="margin-left: 5px;font-size: 13px;" id="dataDe"
				value="#{cotacaoTela.dataDe}" size="6" maxlength="8" mask="99/99/99" />

			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_emissao_ate}" />
			<p:inputMask style="margin-left: 5px;font-size: 13px;" id="dataAte"
				value="#{cotacaoTela.dataAte}" size="6" maxlength="8"
				mask="99/99/99" />

			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_orcamento}" />
			<p:inputText style="margin-left: 5px;" id="nOrca"
				value="#{cotacaoTela.numero}" />

			<p:commandButton value="#{message.botao_filtrar}"
				update=":formCot,:messages,@form"
				action="#{cotacaoTela.filtraOrcamentos}">
			</p:commandButton>

		</h:panelGrid>
	</p:panel>
</h:form>
<h:form id="formCot">
	<p:outputPanel id="orcas" style="width:950px;">
		<p:dataTable value="#{cotacaoTela.listaOrcamentos}" var="orcamento"
			emptyMessage="#{message.table_empty}"
			style="margin-top:20px; width:950px; text-align:center;"
			paginator="true" rows="5">

			<p:column style="width:4%">
				<p:rowToggler />
			</p:column>
			<p:column sortBy="#{orcamento.numero}">
				<f:facet name="header">
					<h:outputText value="#{message.label_numero}" />
				</f:facet>
				<h:outputText value="#{orcamento.numero}" />
			</p:column>
			<p:column sortBy="#{orcamento.comprador.nome}">
				<f:facet name="header">
					<h:outputText value="#{message.label_comprador}" />
				</f:facet>
				<h:outputText value="#{orcamento.comprador.nome}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="#{message.label_endereco}" />
				</f:facet>
				<h:outputText title="#{orcamento.comprador.usuario.endereco}"
					style="cursor:help;"
					value="#{orcamento.comprador.usuario.cidade} - #{orcamento.comprador.usuario.uf}" />
			</p:column>

			<p:column sortBy="#{orcamento.dataEmissao}">
				<f:facet name="header">
					<h:outputText value="#{message.label_dt_emissao}" />
				</f:facet>
				<h:outputText value="#{orcamento.dataEmissao}">
					<f:convertDateTime pattern="dd/MM/yy" />
				</h:outputText>
			</p:column>

			<p:column sortBy="#{orcamento.dataValidade}">
				<f:facet name="header">
					<h:outputText value="#{message.label_dt_validade}" />
				</f:facet>
				<h:outputText value="#{orcamento.dataValidade}">
					<f:convertDateTime pattern="dd/MM/yy" />
				</h:outputText>
			</p:column>

			<p:rowExpansion>
				<p:dataTable value="#{orcamento.itensOrcamento}" var="item"
					emptyMessage="#{message.table_empty}"
					style="margin-top:20px; width:870px; margin-left: 30px; margin-bottom: 20px;">

					<p:column>

						<f:facet name="header">
							<h:outputText value="#{message.label_produto}" />
						</f:facet>
						<h:outputText value="#{item.produto.codigo}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_marca}" />
						</f:facet>
						<h:outputText value="#{item.produto.marca}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_descricao}" />
						</f:facet>
						<h:outputText value="#{item.produto.descricao}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_um}" />
						</f:facet>
						<h:outputText value="#{item.produto.unidadeMedida}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_quantidade}" />
						</f:facet>
						<h:outputText value="#{item.quantidade}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_operacao}" />
						</f:facet>
						<p:commandButton icon="ui-icon-suitcase" onclick="dlgCota.show()"
							id="but_cota" rendered="#{usuario.bloqueado == 'Não'}"
							disabled="#{cotacaoTela.comparaData(orcamento.dataValidade)}">
							<f:setPropertyActionListener value="#{item}"
								target="#{cotacaoTela.item}" />
						</p:commandButton>
						<p:tooltip for="but_cota" value="#{message.tooltip_cotar}"
							showEffect="fade" hideEffect="fade" />
						<p:commandButton
							actionListener="#{cotacaoTela.preparaImagem(item.produto.imagemProd)}"
							onclick="visuProd.show()" update=":visualizaProd"
							icon="ui-icon-image" id="but_img"
							rendered="#{item.produto.imagemProd != null ? true : false}">
						</p:commandButton>
						<p:tooltip for="but_img" value="#{message.tooltip_ver_prod}"
							showEffect="fade" hideEffect="fade" />

					</p:column>

				</p:dataTable>

			</p:rowExpansion>

		</p:dataTable>
	</p:outputPanel>
</h:form>
</html>